package com.adprof.demo.utils;

import android.content.Context;
import android.location.Location;
import android.util.Log;

import com.adprof.demo.android.BuildConfig;
import com.adprof.sdk.AdprofSdk;
import com.adprof.sdk.api.AdprofSdkConfig;
import com.adprof.sdk.api.CustomController;
import com.adprof.sdk.api.InitCallback;

import java.util.HashMap;
import java.util.Map;

public class SDKInitUtil {

    private static final String LOG_TAG = "SDKInitUtil";


    public static void initSDK(Context context, String userId, InitCallback callback) {
        Log.d(LOG_TAG, "开始初始化SDK...");

        // 个性化广告开关设置
        AdprofSdk.getInstance().setPersonalRecommend(true);

        // 自定义数据
        Map<String, Object> customData = new HashMap<>();

        AdprofSdkConfig.Builder configBuilder = new AdprofSdkConfig.Builder()
                .appId(ConstantsDemo.APP_ID)  // 必填
                .appSecret(ConstantsDemo.APP_SECRET)   // 必填
                .userId(userId != null ? userId : "")  // 非必须,  用户ID，有就填
                .showLog(BuildConfig.DEBUG)  // 是否展示 sdk内部日志
                .useHttps(true) // 是否使用 https发起广告请求
                .addCustomData(customData)
                .customController(new CustomController() {

                    @Override
                    public Location getLocation() {
                        return super.getLocation();
                    }

                    @Override
                    public String getImei() {
                        return "";
                    }

                    @Override
                    public String getAndroidId() {
                        return "";
                    }

                    @Override
                    public String getOaid() {
                        return "";
                    }
                })
                .setInitCallback(callback);

        AdprofSdk.getInstance().init(context, configBuilder.build());
    }
}
